import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginVue from "eslint-plugin-vue";

export default [
  { files: ["**/*.{js,mjs,cjs,ts,vue}"] },
  { languageOptions: { globals: globals.browser } },
  // JS 语法规则
  pluginJs.configs.recommended,
  // TS 语法规则
  ...tseslint.configs.recommended,
  // Vue 语法规则
  ...pluginVue.configs["flat/essential"],
  {
    files: ["**/*.vue"],
    languageOptions: { parserOptions: { parser: tseslint.parser } },
  },
  // 定义一些规则
  {
    rules: {
      // 规则，只能使用 let 或 const，不能使用 var
      "no-var": "error",
      "vue/no-v-html": "off",
      "vue/no-setup-props-destructure": "off",
      "vue/no-multiple-template-root": "off",
      "vue/no-v-text": "off",
      "vue/no-v-text-v-html-on-component": "off",
      "vue/no-v-html": "off",
      // 规则：使用单引号而不是双引号
      quotes: ["error", "double"],
      // 规则：使用分号
      semi: ["error", "always"],
      // 规则：使用单行注释
      "line-comment-position": ["error", { position: "above" }],
      // 规则：使用单行注释
      "multiline-comment-style": ["error", "separate-lines"],
      // 规则：使用单行注释
    },
  },
  // 配置忽略文件，忽略 dist 和 node_modules 目录
  { ignores: ["dist", "node_modules"] },
];
